const {fork} = require("child_process");

var childProcess = fork("fork-child.js");
var index = 0;
var intervalID = setInterval(()=>{
    index++;
    childProcess.send("this is message from parent process");
},2000);
    if(index == 10){
        clearInterval(intervalID);
    }
childProcess.on("message",(chunk)=>{
    console.log(chunk);
})